{{extend 'layout.html'}}
{{import os, glob}}
{{block sectionclass}}site{{end}}
<!-- begin "site" block -->
<div class="row-fluid">
	<div class="applist f60 span7">
		<div class="applist_inner">
			<h2>{{=T("Installed applications")}}</h2>
			<ul class="unstyled">
			{{for a in apps:}}
				<li class="application"> <!-- onmouseover="jQuery(this).children('p').show()" onmouseout="jQuery(this).children('p').hide()"-->
				{{if a==request.application:}}
					<h3 class="currentapp muted">{{=a}} ({{=T('currently running')}})</h3>
					<p class="controls row-buttons">
				{{else:}}
					<h3 class="editableapp muted">{{=A(a,_href=URL(a,'default','index'))}}</h3>
					{{if MULTI_USER_MODE and db.app(name=a):}}(created by {{="%(first_name)s %(last_name)s" % db.auth_user[db.app(name=a).owner]}}){{pass}}
					<p class="controls row-buttons">
					{{if not os.path.exists('applications/%s/compiled' % a):}}
						{{=sp_button(URL('design',args=a), T("Edit"))}}
					{{else:}}
						{{=button(URL(a,'appadmin','index'), T("appadmin"))}}
					{{pass}}
						{{=button(URL('about',args=a), T("About"))}}
				{{pass}}
						{{=button(URL('errors',args=a), T("Errors"))}}
						{{=button(URL('cleanup',args=a), T("Clean"))}}
						{{=button(URL('pack',args=a), T("Pack all"))}}
				{{if not os.path.exists('applications/%s/compiled' % a):}}
						{{=button(URL('compile_app',args=a), T("Compile"))}}
				{{else:}}
						{{=button(URL('pack',args=(a, 'compiled')), T("Pack compiled"))}}
					{{if glob.glob('applications/%s/controllers/*.py' % a):}}
						{{=button(URL('remove_compiled_app',args=a), T("Remove compiled"))}}
					{{pass}}
				{{pass}}
				{{if os.path.exists(os.path.join(apath(r=request),a,'.git')): }}
						{{=button(URL('git_pull',args=a), T("Git Pull"))}}
						{{=button(URL('git_push',args=a), T("Git Push"))}}
				{{pass}}
				{{if a!=request.application:}}
						{{=button(URL('uninstall',args=a), T("Uninstall"))}}
						{{=button_enable(URL('enable',args=a), a)}}
				{{pass}}
					</p>
				</li>
			{{pass}}
			</ul>
		</div>
	</div> <!-- /applist -->
	<div class="sidebar fl60 span5">
		<div class="sidebar_inner controls well well-small">
			<!-- CHANGE ADMIN PWD -->
			<div class="pwdchange pull-right">
				{{if MULTI_USER_MODE:}}
					{{=auth.navbar()}}
				{{else:}}
					{{=sp_button(URL('change_password'), T('Change admin password'))}}
				{{pass}}
			</div> <!-- /CHANGE ADMIN PWD -->
			{{if is_manager():}}
			<!-- VERSION -->
			<div class="box">
				<h3>{{=T("Version %s.%s.%s %s (%s)", myversion)}}</h3>
				<p id="check_version" class="row-buttons">
				{{if session.check_version:}}
					{{=T('Checking for upgrades...')}}
				</p>
				<script>ajax('{{=URL('check_version')}}',[],'check_version');</script>
				{{session.check_version=False}}
				{{else:}}
				{{=button("javascript:ajax('"+URL('check_version')+"',[],'check_version')", T('Check for upgrades'))}}
				{{=button(URL('default','reload_routes'), T('Reload routes'))}}
				</p>
				{{pass}}
				<p>{{=T("Running on %s", request.env.server_software)}}</p>
				{{if session.is_mobile=='auto':}}
				<p>{{=A(T('Try the mobile interface'),_href=URL('plugin_jqmobile','about'))}}</p>
				{{pass}}
			</div> <!-- /VERSION -->
			{{pass}}
			{{if MULTI_USER_MODE and is_manager():}}
			<!-- MULTI_USER_INTERFACE -->
			<div class="box">
				<h3>{{=T("Multi User Mode")}}</h3>
				<p class="row-buttons">
				{{=button(URL('bulk_register'),T('Bulk Register'))}}
				{{=button(URL('manage_students',vars={'order':'auth_user.id'}),T('Manage Students'))}}
				</p>
			</div> <!-- /MULTI_USER_INTERFACE -->
			{{pass}}
			<!-- APP WIZARD -->
			<div class="box">
				<h3>{{=T("New application wizard")}}</h3>
				<p>{{=button(URL('wizard','index'), T('Start wizard'))}}
				{{=T("(requires internet access)")}}</p>
			</div> <!-- /APP WIZARD -->
			<!-- SCAFFOLD APP -->
			<div class="box">
				<h3>{{=T("New simple application")}}</h3>
				{{=form_create.custom.begin}}
				{{=LABEL(T("Application name:"))}}
				{{=form_create.custom.widget.name}}
				<div class="controls"><button type="submit" class="btn">{{=T('Create')}}</button></div>
				{{=form_create.custom.end}}
			</div> <!-- /SCAFFOLD APP -->
			<!-- UPLOAD PACKAGE -->
			<div class="box">
				<h3>{{=T("Upload and install packed application")}}</h3>
				{{=form_update.custom.begin}}
				<label for="appupdate_name">{{=T("Application name:")}}</label>
				{{=form_update.custom.widget.name}}
				<label for="appupdate_file">{{=T("Upload a package:")}}</label>
				{{=form_update.custom.widget.file}}
				<label for="appupdate_url">{{=T("Or Get from URL:")}}</label>
				{{=form_update.custom.widget.url}}<small class="help-block">({{=T('can be a git repo')}})</small>
				<div class="controls">
					<label class="checkbox">
						{{=form_update.custom.widget.overwrite}} {{=T("Overwrite installed app")}}
					</label>
					<button type="submit" class='btn'>{{=T('Install')}}</button>
				</div>
				{{=form_update.custom.end}}
			</div> <!-- /UPLOAD PACKAGE -->
			<!-- DEPLOY ON GAE -->
			<div class="box">
				<h3>{{=T("Deploy")}}</h3>
				<p class="row-buttons">
				{{=button(URL('gae','deploy'), T('Deploy on Google App Engine'))}}
				{{=button(URL('openshift','deploy'),T('Deploy to OpenShift'))}}
				</p>
			</div> <!-- /DEPLOY ON GAE -->
			<br/>
			{{if TWITTER_HASH:}}
			<!-- TWITTER -->
			<div class="box">
				<h3>{{=T("%s Recent Tweets"%TWITTER_HASH)}}</h3>
				<div id="tweets">{{=T('loading...')}}</div>
				<script>jQuery(document).ready(function(){jQuery('#tweets').load('{{=URL('twitter.load')}}');});</script>
			</div> <!-- /TWITTER -->
			{{pass}}
		</div>
	</div> <!-- /sidebar -->
</div> <!-- /row-fluid
<!-- end "site" block -->
